//random.cpp
#include "random.h"

U8 RANDAPI_Rand8()
{
	return rand();
}

U16 RANDAPI_Rand16()
{
	U16 uRet;
	RANDAPI_RandByte((BYTE*)&uRet, sizeof(U16));
	return uRet;
}

U32 RANDAPI_Rand32()
{
	U32 uRet;
	RANDAPI_RandByte((BYTE*)&uRet, sizeof(U32));
	return uRet;
}

U64 RANDAPI_Rand64()
{
	U64 uRet;
	RANDAPI_RandByte((BYTE*)&uRet, sizeof(U64));
	return uRet;
}

int RANDAPI_RandByte(BYTE* pOut, int iLen)
{
	if (pOut == NULL || iLen <= 0) return COMMON_ERR_INVALIDARGS;
	for (int i = 0; i < iLen; i++) pOut[i] = RANDAPI_Rand8();
	return 0;
}
